$(function () {
    $(".aqkcdiv2").hide();
    $("#aqkcpe").bootstrapTable({
        method:"post",
        contentType:'application/json',
        url:"/Kucun/aqkcpesjdcx",
        striped:true,
        pageNumber:1,
        pagination:true,
        sidePagination:'server',
        pageSize:3,
        pageList:[2,3,5,6],
        queryParams:function (parmes) {
            return{
                pageNum:(parmes.offset / parmes.limit) + 1,
                pageSize:parmes.limit,
                registerTime:$("#registerTime").val(),
                checked:$("#checked").val(),
            }
        },
        columns:[
            {title:"产品编号",field:"productId",align:'center'},
            {title:"产品名称",field:"productName",align:'center'},
            {title:"用途类型",field:"type",align:'center',
                formatter:function (value,row,index) {
                    if (value==1){
                        return"商品";
                    }
                    if (value==2){
                        return "物料";
                    }
                }},
            {title:"档次级别",field:"productClass",align:'center',
                formatter:function (value,row,index) {
                    if (value==1){
                        return"高档";
                    }
                    if (value==2){
                        return "中档";
                    }
                    if (value==3){
                        return "低档";
                    }
                }
            },
            {title:"I级分类",field:"firstKindName",align:'center'},
            {title:"II级分类",field:"secondKindName",align:'center'},
            {title:"III级分类",field:"thirdKindName",align:'center'},
            {title:"制定设计单",field:"productId",align:'center',
                formatter:function (value,row,index) {
                    var a="<a href='#' onclick='zdsjd("+JSON.stringify(row)+")'>制定设计单</a>";
                    return a;
                }
            },
        ]
    })
})

function aqkzcx() {
    $("#aqkcpe").bootstrapTable("refresh");
}

function zdsjd(row) {
    var date=new Date();
    var n=date.getFullYear();
    var y=date.getMonth()+1;
    var r=date.getDate();
    var s=date.getHours();
    var f=date.getMinutes();
    var m=date.getSeconds();
    var sj=n+"-"+y+"-"+r+" "+s+":"+f+":"+m;

    $("#aqkcdiv1").hide();
    $(".aqkcdiv2").show();

    $("#yiji").html(row.firstKindName);
    $("#erji").html(row.secondKindName);
    $("#sanji").html(row.thirdKindName);
    $("#ytu").html(row.type);

    let na = parent.document.getElementsByClassName("user_name")[0].innerHTML;
    $("#name").html(row.productName);
    $("#bh").html(row.productId);
    $("#djr").val(na);
    $("#djtime").html(sj);
}
function aqkctj() {
    let name=$("#name").html();
    let bh=$("#bh").html();
    let yiji=$("#yiji").html();
    let erji=$("#erji").html();
    let san=$("#sanji").html();
    let yr=$("#ytu").html();
    let bjxx=$("#bjxx").val();
    let bjsx=$("#bjsx").val();
    let ccl=$("#ccl").val();
    let yq=$("#comment").val();
    let djr=$("#djr").val();
    let djtime=$("#djtime").html();

    var aqdx={id:null,productId:bh,productName:name,firstKindName:yiji,secondKindName:erji,thirdKindName:san,minAmount:bjxx
        ,maxAmount:bjsx,maxCapacityAmount:ccl,amount:0,config:yq,register:djr,registerTime:djtime,}
    if (bjxx>0){
        if (parseInt(bjxx) < parseInt(bjsx)){
            if (parseInt(bjsx)<parseInt(ccl)){
                if (confirm("确定提交吗？")){
                    $.ajax({
                        type:"post",
                        contentType:"application/json;charset:utf-8",
                        url:"/Kucun/addaqpe",
                        data:JSON.stringify(aqdx),
                        async:true,
                        success:function (data) {
                            parent.document.getElementById('iframeId').contentWindow.location.reload(true);
                        }
                    })
                }
            }else {
                alert("最大储存量必须高于报警上限")
            }
        }else {
            alert("报警上限必须高于报警下限")
        }
    }else {
        alert("报警下限不能为零")
    }
}

//返回列表
function fanhuiliebiao(){
    $("#aqkcdiv1").show();
    $(".aqkcdiv2").hide();
}